Skip to main content

MusicSystem

Methods


ScheduleAudio

  • Return Type: void

  • Parameters: AudioSource audioSource, float quant = 1, float timeOffset = 0

  • Description: Schedules an audio source to play at a specified quantization time offset.

  • Example:

    MusicSystem.ScheduleAudio(myAudioSource, 2, 0.5f);

GetEngine

  • Return Type: Engine

  • Description: Retrieves the current musical engine instance.

  • Example:

    Engine engine = MusicSystem.GetEngine();

GetTimeToBeat

  • Return Type: float

  • Parameters: float quant, float offset = 0, bool theme = true

  • Description: Gets the number of beats left until the next quantized beat.

  • Example:

    float timeToBeat = MusicSystem.GetTimeToBeat(4);

GetRealTimeToBeat

  • Return Type: float

  • Parameters: float quant

  • Description: Converts the time to beat into real time duration.

  • Example:

    float realTime = MusicSystem.GetRealTimeToBeat(4);

GetNextBeat

  • Return Type: float

  • Parameters: float quant, float offset = 0, bool theme = true

  • Description: Retrieves the beat position of the next quantized beat. A quantized beat means the next occurence of said multiple. A value of "4" will return the next beat multiple of 4; 0, 4, 8, 12 etc. A value of 1 will return every rounded beat.

  • Example:

    float nextBeat = MusicSystem.GetNextBeat(4);

GetNextBeatAbsolute

  • Return Type: long

  • Parameters: float quant, float offset = 0, bool theme = true

  • Description: Returns the absolute value of the next quantized beat.

  • Example:

    long absoluteBeat = MusicSystem.GetNextBeatAbsolute(4);

GetCurrentBeat

  • Return Type: float

  • Description: Retrieves the current beat position.

  • Example:

    float currentBeat = MusicSystem.GetCurrentBeat();

GetCurrentMicroBeat

  • Return Type: double

  • Description: Retrieves the current beat position with micro precision.

  • Example:

    double microBeat = MusicSystem.GetCurrentMicroBeat();

GetTempoBpm

  • Return Type: float

  • Description: Retrieves the tempo in beats per minute.

  • Example:

    float bpm = MusicSystem.GetTempoBpm();

BeatsToSeconds

  • Return Type: float

  • Parameters: float beats

  • Description: Converts beat value into seconds based on the current BPM.

  • Example:

    float seconds = MusicSystem.BeatsToSeconds(4);

DuckMusic

  • Return Type: IEnumerator

  • Parameters: float amp

  • Description: Gradually reduces the music volume by a specified amplitude.

  • Example:

    StartCoroutine(MusicSystem.DuckMusic(0.5f));

Properties


PlaybackAllowed

  • Type: bool

  • Description: Get or set whether playback is allowed.

  • Example:

    // Setting PlaybackAllowed
    MusicSystem.PlaybackAllowed = true;

    // Getting PlaybackAllowed
    bool isAllowed = MusicSystem.PlaybackAllowed;

Enumerators


Quant

  • Values:
    Whole     = 1
    Half = 2
    Quarter = 4
    Eighth = 8
    Sixteenth = 16
  • Description: Represents musical quantization values.

PlaybackState

  • Values:
    Stopped = 0
    Playing = 1
    Paused = 2
  • Description: States of music playback.

Classes


WaitForNextBeat

  • Description: Custom yield instruction that waits for the next quantized beat.

  • Example:

    yield return new MusicSystem.WaitForNextBeat(4);